/**
 * wikiletter.net Inc.
 * Copyright (c) 2011 All Rights Reserved.
 */
package org.yaya.platform.locker.enums;

import java.util.ArrayList;
import java.util.List;

/**
 *                       
 * @Filename: LockerResultCodeEnum.java
 *
 * @Description: 
 *
 * @Version: 1.0
 *
 * @Author: peigen
 *
 * @Email: peigen123@gmail.com
 *
 *       
 * @History:<br>
 *<li>Author: peigen</li>
 *<li>Date: 2011-7-26</li>
 *<li>Version: 1.0</li>
 *<li>Content: create</li>
 *
 */
public enum LockerResultCodeEnum {

    /** 未知异常 */
    UN_KNOWN_EXCEPTION("UN_KNOWN_EXCEPTION", "未知异常"),

    /** 执行成功 */
    EXECUTE_SUCCESS("EXECUTE_SUCCESS", "执行成功");

    /** 枚举值 */
    private final String code;

    /** 枚举描述 */
    private final String message;

    /**
     * 构造一个<code>LockerResultCode</code>枚举对象
     * @param code
     * @param message
     */
    private LockerResultCodeEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 构造一个<code>LockerResultCode</code>枚举对象
     * @return Returns the code.
     */
    public String getCode() {
        return code;
    }

    /**
     * @return Returns the message.
     */
    public String getMessage() {
        return message;
    }

    /**
     * @return Returns the code.
     */
    public String code() {
        return code;
    }

    /**
     * @return Returns the message.
     */
    public String message() {
        return message;
    }

    /**
     * 通过枚举<code>code</code>获得枚举
     * @param code
     * @return
     */
    public static LockerResultCodeEnum getByCode(String code) {
        for (LockerResultCodeEnum cacheCode : values()) {
            if (cacheCode.getCode().equals(code)) {
                return cacheCode;
            }
        }
        return null;
    }

    /**
     * 获取全部枚举
     * 
     * @return
     */
    public List<LockerResultCodeEnum> getAllEnum() {
        List<LockerResultCodeEnum> list = new ArrayList<LockerResultCodeEnum>();
        for (LockerResultCodeEnum cache : values()) {
            list.add(cache);
        }
        return list;
    }

    /**
     * 获取全部枚举值
     * 
     * @return
     */
    public List<String> getAllEnumCode() {
        List<String> list = new ArrayList<String>();
        for (LockerResultCodeEnum cache : values()) {
            list.add(cache.code());
        }
        return list;
    }
}
